﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 飞机大战.Properties;

namespace 飞机大战
{
    public class BackGround : Game
    {
        /// <summary>
        /// 导入背景图片
        /// </summary>
        private static Image imgBG = Resources.background;

        /// <summary>
        /// 写构造函数去调用父类Game的构造函数
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="speed"></param>
        public BackGround(int x, int y, int speed)
            : base(x, y, imgBG.Width, imgBG.Height, speed, 0, Direction.down)
        { }

        public override void Draw(Graphics g)
        {
            this.Y += this.Speed;

            if (this.Y == 0)
            {
                this.Y = -850;
            }

            //坐标改变后，将背景图像不停地绘制到窗体中
            g.DrawImage(imgBG, this.X, this.Y);
        }
    }
}
